#include "Jobs.h"

Job::Job() {
    args = NULL;
}

Job::~Job() {
    switch (type) {
        case BROADCAST_JOIN:
        case BROADCAST_LEAVE:
        case EXITLISTENER:
        case EXITWORKER:
            break;
        case REPLYSTATUS:
            close( ((QueryStatusArgs *)args)->clntSocket );
            delete (QueryStatusArgs *)args;
            break;
        case QUERYCHUNK:
            delete (ChunkRequestArgs *)args;
            break;
        case BROADCAST_RECEIVEDCHUNK:
            delete (ReceivedChunkArgs *)args;
            break;
        case WANTCHUNK: 
            close( ((ReplyChunkArgs *)args)->clntSocket );
            delete (ReplyChunkArgs *)args;
            break;
        case DONTWANTCHUNK:
            close( ((ReplyChunkArgs *)args)->clntSocket );
            delete (ReplyChunkArgs *)args;
            break;
        case QUERYSTATUS:
            close( ((QueryStatusArgs *)args)->clntSocket );
            delete (QueryStatusArgs *)args;
            break;
        case BROADCAST_NEWFILE:
            delete (NewFileArgs *)args;
            break;
        default:
            printf("invalid Job type...wtf!!!\n");
            break;
    }
}

